home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 2
/
Gekikoh Dennoh Club Vol. 2 (Japan).7z
/
Gekikoh Dennoh Club Vol. 2 (Japan) (Track 01).bin
/
kowin
/
font
/
fonted31.lzh
/
fonted3.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-01-29
|
7KB
|
297 lines
/*/ ******************************************************************* /*/
/*/ /*/
/*/ FONTED3.win version 1.10 1990 10/24 by 小笠原博之 /*/
/*/ SPS0783 COR. /*/
/*/ /*/
/*/ v1.10 1991 1/29: Ko-Window 2.07 対応、高速化、デバッグ /*/
/*/ ******************************************************************* /*/
#include <stdio.h>
#include <wlib.h>
#include <parts.h> /**/
#include "fed3const.h"
#include "fonted3.h"
#include "mpat.h"
/*/
/* イベント定義
/*/
#define EVENT (EventOpenON \
|EventRedrawON \
|EventCloseON \
|EventUserON \
|EventMouseSwitchON)
/*//////////////////////////////////////////////////////////////////////*/
/* グローバル宣言 */
/*//////////////////////////////////////////////////////////////////////*/
/*** function ***/
int EventExec();
/*** heap size ***/
int WindowHeapSize =
/*### Edit Screen ###*/
BITSIZEX*BITSIZEY*2/8 +
/*### TC hankaku Screen ###*/
4096 /*+*/
/*### TC zenkaku Screen ###*/
/* 1024*10 +*/
/*### USKCG Screen ###*/
/* 1024*10 */;
Sheet *EditScreen= 0;
ClipClass EditClip= {
0, 0, BITSIZEX-1, BITSIZEY-1
},
ImgClip= {
0, 0, EDITSIZEX-1, EDITSIZEY-1
};
unsigned short ImgBuf[EDITSIZEY],
ImgBuf2[EDITSIZEY];
Sheet ImgArea ={
16,
16,
1,
(short*)ImgBuf,
(short*)ImgBuf2
};
EventInfo *Ainfo;
DrawBuf dbuf_1[60];
DrawBuf dbuf_2[2];
/*//////////////////////////////////////////////////////////////////////*/
/* メインルーチン */
/*//////////////////////////////////////////////////////////////////////*/
void
WindowMain( argc, argv )
char **argv;
{
int x,
y;
/*/
/* オプション解析
/*/
for( x= y= 2 ; --argc ; ){
if( **++argv == '-' || **argv == '/' ){
switch( (*argv)[1] ){
case 'x':
x= atoi( *argv+2 );
break;
case 'y':
y= atoi( *argv+2 );
break;
}
}
}
/*/
/* ウィンドウ設定
/*/
WindowSetEventAttr( WindowTitleOpen( x, y, BITSIZEX+128+5, BITSIZEY+60, NULL, WINDOWTITLE, Close|Push, EventExec ), EVENT );
}
/*//////////////////////////////////////////////////////////////////////*/
/* イベント処理ルーチン */
/*//////////////////////////////////////////////////////////////////////*/
EventExec( wp, info )
WindowID wp;
EventInfo *info;
{
switch( info->option ){
case EventOpen:
Init_EditScreen();
Draw_EditScreen_init( wp );
WindowRedraw( wp );
return TRUE;
case EventRedraw:
WindowDraw( wp, dbuf_1, 5+SWNUMX*SWNUMY*2 );
return TRUE;
case EventClose:
if( EditScreen )
SheetClose( EditScreen );
WindowClose( wp );
WindowConnectionClose();
return TRUE;
case EventUser: {
char **data= info->ComBuffer;
char *ptr;
switch( info->ComData ){
case UserStrings:
(char*)(info->ComBuffer)= *(char**)(info->ComBuffer);
case UserPaste:
case UserString:
areamsg( wp, "ロード中" );
if( loadfont( info->ComBuffer ) ){
ImgtoEdit();
WindowDraw( wp, dbuf_2, 2 );
areamsg( wp, "ロード終了" );
}else
areamsg( wp, "open error!" );
return TRUE;
/* default: */
case 256:
if( data && !*data++ && (ptr= *data++) && *ptr=='\0' && strcmp( ptr+1, "FontData" )== 0 ){
unsigned short *sptr= *((unsigned short**)(++data));
int i;
for( i=0 ; i<16 ; i++ )
ImgBuf[i]= *sptr++;
ImgtoEdit();
WindowDraw( wp, dbuf_2, 2 );
}
}
return TRUE;
}
case EventMouseSwitch:
if( info->LeftStat || info->RightStat ){
if( info->x > EDITOFFX && info->x < EDITOFFX+BITSIZEX &&
info->y > EDITOFFY && info->y < EDITOFFY+BITSIZEY ){
Pset_EditScreen(
(info->x-EDITOFFX)/DOTSIZEX,
(info->y-EDITOFFY)/DOTSIZEY,
info->LeftStat, TRUE, wp );
return TRUE;
}
}
if( info->LeftON ){
Ainfo= info;
if( info->x >SWOFFX && info->x <SWOFFX+SWSIZEX*SWNUMX &&
info->y >SWOFFY && info->y <SWOFFY+SWSIZEY*SWNUMY ){
int swx= (info->x - SWOFFX)/SWSIZEX,
swy= (info->y - SWOFFY)/SWSIZEY;
swmode[swx*SWNUMY+swy].exec( wp );
return TRUE;
}
send_font( wp );
}
return TRUE;
}
return FALSE;
}
/*//////////////////////////////////////////////////////////////////////*/
/* 表示バッファ設定 */
/*//////////////////////////////////////////////////////////////////////*/
Draw_EditScreen_init( wp )
WindowID wp;
{
int i;
int j;
DrawBuf *buf;
DrawSetClear( dbuf_1, 1 );
DrawSetPut( dbuf_1+1, EDITOFFX, EDITOFFY, EditScreen );
DrawSetPut( dbuf_1+2, IMGOFFX, IMGOFFY, &ImgArea );
DrawSetLine( dbuf_1+3, EDITOFFX-3, EDITOFFY-2, EDITOFFX+BITSIZEX+1,
EDITOFFY+BITSIZEY+1, 3, OptionBox );
DrawSetLine( dbuf_1+4, MSGOFFX-2, MSGOFFY-1, MSGOFFX+6*14+2, MSGOFFY+14, ShadowDown, OptionShadow );
buf= dbuf_1+5;
for( j=0 ; j< SWNUMX ; j++ ){
for( i=0 ; i< SWNUMY ; i++ ){
DrawSetSymbol( buf++, SWOFFX+j*(SWSIZEX+4), SWSIZEY*i+SWOFFY, swmode[j*SWNUMY+i].name, AttrDefault, 12 );
DrawSetLine( buf++, SWOFFX-2+j*(SWSIZEX+4), SWSIZEY*i+SWOFFY, SWOFFX+SWSIZEX+1+j*(SWSIZEX+4), SWSIZEY*i+SWOFFY+SWSIZEY-1, ShadowUp, OptionShadow );
}
}
/* dbuf_1 == (5+SWNUMX*SWNUMY*2) */
DrawSetPut( dbuf_2, EDITOFFX, EDITOFFY, EditScreen );
DrawSetPut( dbuf_2+1, IMGOFFX, IMGOFFY, &ImgArea );
}
/*//////////////////////////////////////////////////////////////////////*/
/* ビットマップバッファの確保 */
/*//////////////////////////////////////////////////////////////////////*/
Init_EditScreen()
{
int x,
y;
int i;
if( EditScreen == 0 )
EditScreen= (Sheet*)SheetOpen( BITSIZEX, BITSIZEY );
SheetClear( EditScreen, &EditClip, 1 );
SheetClear( &ImgArea, &ImgClip, 1 );
}
/*//////////////////////////////////////////////////////////////////////*/
/* 点の描画 */
/*//////////////////////////////////////////////////////////////////////*/
Pset_EditScreen( x, y, c, mode, wp )
int x,
y,
c,
mode;
WindowID wp;
{
int rx1= x*DOTSIZEX,
ry1= y*DOTSIZEY,
rx2,
ry2;
SheetLine( EditScreen, &EditClip, rx1, ry1, rx2=rx1+DOTSIZEX-2, ry2=ry1+DOTSIZEY-2,
!c, OptionFill );
if( c )
ImgArea.buf1[y] &=~(32768>>x);
else
ImgArea.buf1[y] |= (32768>>x);
if( mode ){
DrawBuf buf[2];
DrawSetLine( buf, rx1+EDITOFFX, ry1+EDITOFFY, rx2+EDITOFFX, ry2+EDITOFFY,
!c, OptionFill );
DrawSetPut( buf+1, IMGOFFX, IMGOFFY, &ImgArea );
WindowDraw( wp, buf, 2 );
}
}
/*//////////////////////////////////////////////////////////////////////*/
/* send font */
/*//////////////////////////////////////////////////////////////////////*/
send_font( wp )
WindowID wp;
{
WindowID cwp;
EventInfo info2;
mspatset();
mspat(1);
while( !(WindowGetEventInfo(Ainfo) && Ainfo->LeftOFF) );
cwp= WindowGetChild( WindowRootID, Ainfo );
if( cwp && cwp != wp ){
/*unsigned short fontbuf[16];*/
CodePack pack;
void *compack[4]= {
(void*)0,
(void*)"\0FontData",
(void*)&pack,
(void*)ImgBuf/*fontbuf*/
};
/* int i;
for( i=0 ; i<16 ; i++ )
fontbuf[i]= ImgBuf[i];
*/
pack.xsize= 16;
pack.ysize= 16;
pack.code = 1;
pack.sendx= Ainfo->x;
pack.sendy= Ainfo->y;
info2.option= EventUser;
info2.ComBuffer= compack;
info2.ComData= 256;
WindowSendEvent( cwp, &info2 );
}
mspat(0);
}